import * as THREE from "three";
import {
  scene
} from "../utils/three-base";

// 基于箭头原点方向的向量
const dirX = new THREE.Vector3(1, 0, 0);
// 对三维向量进行归一化
dirX.normalize();
// 基于箭头原点方向的向量
const dirY = new THREE.Vector3(0, 1, 0);
// 对三维向量进行归一化
dirY.normalize();
// 基于箭头原点方向的向量
const dirZ = new THREE.Vector3(0, 0, 1);
// 对三维向量进行归一化
dirZ.normalize();
// 原点
const origin = new THREE.Vector3(0, 0, 0);
// 箭头长度
const arrowLength = 1;

export const renderArrowHelper = (len) => {
  let arrLen = len || arrowLength;
  // 创建三维箭头辅助对象
  const createArrowXHelper = new THREE.ArrowHelper(dirX, origin, arrLen, 0xff0000);
  const createArrowYHelper = new THREE.ArrowHelper(dirY, origin, arrLen, 0x00FF00);
  const createArrowZHelper = new THREE.ArrowHelper(dirZ, origin, arrLen, 0x0000FF);


  // 把模拟方向的三维箭头x轴添加到场景
  scene.add(createArrowXHelper);
  // 把模拟方向的三维箭头y轴添加到场景
  scene.add(createArrowYHelper);
  // 把模拟方向的三维箭头z轴添加到场景
  scene.add(createArrowZHelper);
}